﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Craftsman.Core.Domain;
using Craftsman.Core.Infrastructure.Logging;
using Craftsman.Core.Runtime;
using Microsoft.AspNetCore.Mvc;
using Craftsman.Core.Web;
using Craftsman.xCoronavirus.Domain.Entities;
using Craftsman.Core.ObjectMapping;
using Craftsman.xCoronavirus.Domain;

namespace Craftsman.xCoronavirus.WebApis.Controllers
{
    [Route("api/questionnaires")]
    [ApiController]
    public class QuestionnaireController : ControllerBase, IController
    {
        private ILogger _logger;
        private ISession _session;
        private IObjectMapper _objectMapper;
        public IQuestionnaireService _questionnairService { get; set; }

        public QuestionnaireController(
            ILogger logger,
            ISession session,
            IObjectMapper objectMapper,
            IQuestionnaireService questionnairService
        )
        {
            _logger = logger;
            _session = session;
            _objectMapper = objectMapper;
            _questionnairService = questionnairService;
        }


        #region questionnair

        // GET: api/questionnaires
        [HttpGet]
        public PagingDataRespone<Questionnaire> GetAllQuestionnaires(QuestionnaireStatus status)
        {
            var datas = _questionnairService.GetQuestionnaires(status);
            return new PagingDataRespone<Questionnaire>() { Data = datas, Pagination = new Pagination() };
        }

        // GET api/questionnaires/{guid}
        [HttpGet("{id}/get")]
        public Questionnaire GetQuestionnaire([FromRoute]string id)
        {
            return _questionnairService.GetQuestionnaire(id);
        }

        // GET api/questionnaires/{guid}/pass
        [HttpGet("{id}/pass")]
        public IActionResult PassQuestionnaire([FromRoute]string id)
        {
            _questionnairService.PassQuestionnaire(id);
            return NoContent();
        }

        [HttpDelete("{id}/invalid")]
        public IActionResult InvalidQuestionnaire([FromRoute]string id)
        {
            _questionnairService.InvalidQuestionnaire(id);
            return NoContent();
        }

        #endregion modify_requests

    }
}
